<?php

	class wedding
	{
		private $db;
		
		function __construct()
		{
			$this->db = new D("blessing");
		}
		
		function dodefault(){
			$this->doindex();
		}
		
		function doindex(){
			
			$arr = $this->db->select();
			
			logger::json($arr);
		}
		
		function doget(){
			$id = $_REQUEST["id"];//echo($id);
			$arr = $this->db->select("id=".$id); //"id="+$id , "*"
			logger::json($arr , true);
		}
		
		function docreat(){
			//增
			//echo $hj->insert(array("NULL","1@qq.com","xxx"));
			//echo $hj->insert(array("name"=>"ESRI","type"=>0));
			//,"copyright"=>"Tiles &copy; <a href='http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer'>ESRI</a>"
			//echo $hj->insert("NULL,'123@qq.com','cde'");
			$result = $this->db->insert($_POST);
			if($result)
				logger::success($result);
			else
				logger::success("error");
		}
		
		function dodelete($v){}
		
		function doupdate(){
			$id = $_REQUEST["id"];
			if($id == "0"){
				echo("0");
			}
			else{
				$req = $_POST;
				// echo(is_array($req));
				// foreach ($req as $key=>$value) {
					// if($key == "name")
						// array_push($arr,$key=>$value);
				// }
				//echo("id=$id");
				//print_f($_POST);
				$result = $this->db->update("id=$id",$_POST);
				if($result == 0)
					logger::success("success");
				else
					logger::success("error");
			}
		}
	}
?>